#!/bin/bash

killall lighttpd
killall memcached
memcached -d -m 2048 -p 11211 -u root

# Replace these three settings.
PROJDIR="/home/mercury/safecenter"
PIDFILE="$PROJDIR/safecenter.pid"
SOCKET="$PROJDIR/safecenter.sock"

cd $PROJDIR
if [ -f $PIDFILE ]; then
    kill `cat -- $PIDFILE`
    rm -f -- $PIDFILE
fi
python $PROJDIR/manage.py runfcgi method=prefork maxrequests=1000 maxspare=80 minspare=20 socket=$SOCKET pidfile=$PIDFILE daemonize=true
/usr/sbin/lighttpd -f $PROJDIR/lighttpd.conf